﻿@using KRM.Core
@model List<KRM.Core.tblTaskHistory>
@{
    ViewBag.Title = "View Log Task History";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";;
    var lstLogType = ViewBag.LstLogType as List<tblLogType>;
}
<div style="padding: 10px">
    <div class="row-fluid" >
        <form action="/Task/ViewLogTaskHistory" method="GET" style="margin: 0">
            <div class="span2">
                <label class='inline' for="UserAction">Task type:</label>
                @Html.DropDownList("TypeId",null,new{@onchange="this.form.submit()",@class="input-block-level"})
            </div>

            <div class="span2">
                <input style="float: left;"  type="checkbox" name="FilterByDateFrom" id="FilterByDateFrom" value="1"  @(Request["FilterByDateFrom"]=="1"?"checked=checked":"")/>
                <label class='inline' for="FilterByDateFrom">Date From</label>
                <div id="datetimepicker2" class="input-append">
                    <input data-format="MM/dd/yyyy" type="text" name="dateFrom" placeholder="From" value="@(Request["dateFrom"]??DateTime.Now.ToString("MM/dd/yyyy"))" style="width: 76%">
                    <span class="add-on">
                        <i data-time-icon="icon-time" data-date-icon="icon-calendar" class="icon-calendar"></i>
                    </span>
                </div>
            </div>
            <div class="span2">
                <input style="float: left;" type="checkbox" name="FilterByDateTo"id="FilterByDateTo" value="1" @(Request["FilterByDateTo"]=="1"?"checked=checked":"")/>
                <label class='inline' for="FilterByDateTo">Date To</label>
                <div id="datetimepicker3" class="input-append">
                    <input data-format="MM/dd/yyyy" type="text" name="dateTo" placeholder="To" value="@(Request["dateTo"]??DateTime.Now.ToString("MM/dd/yyyy"))" style="width: 76%">
                    <span class="add-on">
                        <i data-time-icon="icon-time" data-date-icon="icon-calendar" class="icon-calendar"></i>
                    </span>
                </div>
            </div>
            <div class="span2">
                <label class='inline' for="TaskId">Task id:</label>
                <input name="TaskId"id="TaskId" class="input-block-level" type="number" data-val="true" data-val-number="TaskID must be a number."  value="@Request["TaskId"]">
            </div>
            <div class="span2">
                <label class='inline' for="UserAction">User action:</label>
                <input type="text" name="UserAction" id="UserAction" class="input-block-level" value="@Request["UserAction"]">
            </div>
            <div class="span2" style="padding-top: 25px;">
                <button type="submit" class="btn btn-primary">Search</button>
                <a class="btn btn-default" id="resetFilter" href="/Task/ViewLogTaskHistory">Clear</a>
                
            </div>
        </form>
    </div>
    <div class="row-fluid">
        <div class="fixhead" style="max-height: 500px;overflow: auto;border-bottom: 1px solid #D8D8D8;">
            <table class="table table-bordered table-fix">
                <thead>
                    <tr>
                        <th>TaskID</th>
                        <th>OrderRef</th>
                        <th>User Name</th>
                        <th>Action Time</th>
                        <th>Type</th>
                        <th>Previous Assigned To Username</th>
                        <th>Assigned To Username</th>
                        <th>Extra Info</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model)
                    {
                        <tr>
                           <td><a href="#" onclick="PopupCenter('/orderview/viewtask/@item.TaskId?orderref=@item.OrderRef', 600, 540)" style="cursor: pointer" title="View Task">@item.TaskId</a></td>
                            <td><a href="/orderview/orderdetail?OrderRef=@item.OrderRef" target="blank" style="cursor: pointer" title="View Order">@item.OrderRef</a></td>
                            <td>@item.Username</td>
                            <td>@((item.ActionTime??DateTime.Now).ToString("MM/dd/yyyy HH:mm"))</td>
                            <td>
                                @{
                                    var firstOrDefault = lstLogType.FirstOrDefault(p => p.LogTypeId == item.TypeID);
                                }
                                @if (firstOrDefault != null)
                                {
                                    @firstOrDefault.Name
                                }
                            </td>
                            <td>@item.PreviousAssignedToUsername</td>
                            <td>@item.AssignedToUsername</td>
                            <td>@item.ExtraInfo</td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>






